﻿using AnlianCommon.Common.Domains.ProductionManagement;
using AnlianCommon.Common.DTO;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SheepCommon.API.Crossbreedings;

namespace SheepCommon.API.Controllers
{
    /// <summary>
    /// 后裔转钟
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class CrossbreedingController : ControllerBase
    {
        private readonly IMediator _mediator;

        public CrossbreedingController(IMediator mediator)
        {
            _mediator = mediator;
        }
        /// <summary>
        /// 后裔转种添加
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> CreateCrossbreeding(CrossbreedingCreateCommand request, CancellationToken cancellationToken)
        {
            return await _mediator.Send(request, cancellationToken);
        }
        /// <summary>
        /// 后裔转钟查询显示
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultPage<CrossbreedingSearchDto>> SearchCrossbreeding(CrossbreedingSearchCommand request, CancellationToken cancellationToken)
        {
            return await _mediator.Send(request, cancellationToken);
        }
    }
}
